var mapa = {
	id: "mapa",

	_nivel: [],

	visible: true,

	init: function () {
		this._nivel[0] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        this._nivel[1] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        this._nivel[2] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        this._nivel[3] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[4] = [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[5] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[6] = [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[7] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[8] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[9] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[10] = [0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0];
		this._nivel[11] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
		this._nivel[12] = [0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0];
		this._nivel[13] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
		this._nivel[14] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
	},

	update: function (delta) {
	},

	draw: function (context) {

		context.save();
			for (var i = 0; i < this._nivel.length; i++) {
				for (var j = 0; j < this._nivel[i].length; j++) {
					if (this._nivel[i][j] !== 0) {
							context.drawImage(jsGFwk.ResourceManager.graphics.sprites.image,
							373, 47, 16, 16, 
							(j * 16), (i * 16), 16, 16);
					}
				}
			}
		context.restore();
	},

	_getGridRelation: function (x, y) {
		var cx = Math.floor(x / 16);
		var cy = Math.floor(y / 16);
		return { 
			currentX: cx,
			currentY: cy,
			currentMatrixPosition: jsGFwk._gameObjects.mapa._nivel[cy][cx],
			positions: {
				topMatrixPosition: (cy - 1 >= 0 ? jsGFwk._gameObjects.mapa._nivel[cy - 1][cx] : null),
				rightMatrixPosition: (cx + 1 <= jsGFwk._gameObjects.mapa._nivel[0].length ? jsGFwk._gameObjects.mapa._nivel[cy][cx + 1] : null),
				bottomMatrixPosition: (cy + 1 <= jsGFwk._gameObjects.mapa._nivel.length ? jsGFwk._gameObjects.mapa._nivel[cy + 1][cx] : null),
				leftMatrixPosition: (cx - 1 >= 0 ? jsGFwk._gameObjects.mapa._nivel[cy][cx - 1] : null)
			}
		};
	},
};